<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <input type="text" id="txt">
  <input type="button" id="btn" value="搜索">
  <table border="1" width="600">
    <thead>
      <tr>
        <th>ID</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
      </tr>
    </thead>
    <tbody>
      <!-- <tr>
        <td>1</td>
        <td>zs</td>
        <td>35</td>
        <td>男</td>
      </tr> -->
    </tbody>
  </table>
  <script>
    document.getElementById('btn').onclick = function(){
      var valuekey = document.getElementById('txt').value;
      var xhr = new XMLHttpRequest();
      xhr.open('get','/api/searchStudent?name='+valuekey);
      xhr.send();
      xhr.onload = function(){
        var result = JSON.parse(xhr.responseText);
        var str = '';
        result.forEach(function(item){
          str += '<tr>'
          str += '<td>'+item.id+'</td>'
          str += '<td>'+item.name+'</td>'
          str += '<td>'+item.age+'</td>'
          str += '<td>'+item.gender+'</td>'
          str += '</tr>'
        });
        document.querySelector('tbody').innerHTML = str;
      }
    }
  </script>
</body>
</html>